package com.ambow.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ambow.dao.SysUserMapper;
import com.ambow.pojo.SysUser;
import com.ambow.pojo.SysUserExample;
import com.ambow.service.SysUserService;;

/** 
* @author 黄广展
* @date 2018年9月8日 上午8:52:14
* @Description 
* @version V1.0
*/
@Service(value="sysUserService")
public class SysUserServiceImpl implements SysUserService{
	@Autowired
	private SysUserMapper sysUserMapper;
	/**
	 * 根据Id查询
	 */
	@Override
	public SysUser findById(String userId) {
		SysUser sysUser = sysUserMapper.selectByPrimaryKey(userId);
		return sysUser;
	}
	/**
	 * 查询所有对象
	 */
	@Override
	public List<SysUser> findAll() {
		SysUserExample example = new SysUserExample();
		List<SysUser> list = sysUserMapper.selectByExample(example);
		return list;
	}
	/**
	 * 添加
	 */
	@Override
	public int add(SysUser sysUser) {
		int a = 0;
		 a = sysUserMapper.insert(sysUser);
		return a;
	}
	/**
	 * 更新系统用户
	 */
	@Override
	public int update(String userId) {
		SysUser sysUser = sysUserMapper.selectByPrimaryKey(userId);
			sysUser.setUsername("yy");
			int c = 0;
		 c = sysUserMapper.updateByPrimaryKey(sysUser);
		return c;
	}

	/**
	 * 删除系统用户
	 */
	@Override
	public int delete(String userId) {
		int b = 0;
		 b = sysUserMapper.deleteByPrimaryKey(userId);
		return b;
	}

}
